package leetcode.code1567;

import java.util.Iterator;

import leetcode.IDebug;
import leetcode.helper.H;

public class Solution implements IDebug {

	public int getMaxLen(int[] nums) {
		int ans = 0;
		for (int i = 0, z = 0, f = 0; i < nums.length; i++) {
			int num = nums[i];
			if (num == 0) {
				z = 0;
				f = 0;
			} else if (num > 0) {
				z++;
				f = f > 0 ? f + 1 : 0;
			} else {
				int t = z;
				z = f > 0 ? f + 1 : 0;
				f = t + 1;
			}
			ans = Math.max(ans, z);
		}
		return ans;
	}

	@Override
	public void debug4() {
		H.compare(6, this.getMaxLen(H.str2array3("[-16,0,-5,2,2,-13,11,8]")));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
